﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CgSilverlightDynamicGeometry;
using System.Windows.Controls.Primitives;
using CgPipeSectionDisplay.Controls;

namespace CgPipeSectionDisplay
{
    public partial class CoordinatePanel : UserControl
    {
        public Drawing Drawing { get; set; }
        private Popup pop = new Popup();
        private PopupControl control = new PopupControl();
        public CoordinatePanel()
        {
            InitializeComponent();
            this.LayoutRoot.Width = 800;
            this.LayoutRoot.Height = 400;
            Drawing = new Drawing(this.LayoutRoot);
        }

        private void LayoutRoot_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Drawing.CoordinateSystem.Init();
        }

        private void Ellipse_MouseEnter(object sender, MouseEventArgs e)
        {
            var point = e.GetPosition(this);
            pop.Child = control;
            control.PopupText = "测试Text";
            pop.IsOpen = true;
            pop.HorizontalOffset = point.X;
            pop.VerticalOffset = point.Y;
        }

        private void Ellipse_MouseLeave(object sender, MouseEventArgs e)
        {
            pop.IsOpen = false;
        }

        private void Ellipse_MouseMove(object sender, MouseEventArgs e)
        {
            
        }
    }
}
